<template>
    <div class="wrap" v-loading="loading">
        <div class="admin-login-background">
            <div class="layui-form">
                <div>
                    <i class="layui-icon layui-icon-username admin-icon admin-icon-username"></i>
                    <input type="text" name="username" v-model="username" placeholder="请输入用户名"
                        autocomplete="off"
                        class="layui-input admin-input admin-input-username">
                </div>
                <div>
                    <i class="layui-icon layui-icon-password admin-icon admin-icon-password"></i>
                    <input type="password" name="password" v-model="password"
                        placeholder="请输入密码"
                        autocomplete="off"
                        class="layui-input admin-input admin-input-verify">
                </div>
                <button class="layui-btn admin-button" lay-submit lay-filter="formDemo" @click="click">登录</button>
            </div>
        </div> 
        <ul class="bg-bubbles">
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
		</ul>
    </div>
        
</template>
<script>
import { mapMutations,mapActions, mapState } from 'vuex';
import { kf_key } from '@/config/'
export default {
    data(){
        return { 
            username:'',password:'',
            loading:false
            }
    },
    created(){
        let params = sessionStorage.getItem(btoa('kf-certificate') )
        if(params){
            params = JSON.parse(atob(params))
            this.submit(params)
        }   
    },
    computed:{
        ...mapState(['accountListMap','uistate']),
    },
    methods:{
        ...mapActions(['login']),
        ...mapMutations(['updateUIState']),
        click(){
            this.submit()
        },
        submit(params){
            if(!params){
                if(this.username.trim()===''){
                return this.$msg('请输入用户名')
                }
                if(this.password===''){
                    return this.$msg('请输入密码')
                }
            }
            params = params||{ username:this.username,password:this.password }
            this.loading = true
            this.login(params)
                .then(rs=>{
                    if(!params)this.$msg('登录成功')
                    sessionStorage.setItem(btoa(kf_key),btoa(JSON.stringify(params)))
                    const accountid = this.accountListMap[this.uistate.adminid][0]
                    this.updateUIState({ accountid })
                    this.loading = false
                }).catch(e=>{
                    this.$msg(e);
                    this.loading = false
                })
            return false    
        }
    }
}
</script>
<style scoped>
.wrap{
    height: 100%;
    background: #50a3a2;
    background: -webkit-linear-gradient(top left, #50a3a2 0%, #53e3a6 100%);
    background: linear-gradient(to bottom right, #50a3a2 0%, #53e3a6 100%);  
    display: flex;
    justify-content: center;
    align-items: center  
}

input:-webkit-autofill {
    -webkit-box-shadow: inset 0 0 0 1000px #fff;
    background-color: transparent;
}
.admin-login-background {
    width: 300px;
    z-index: 1;
    background: rgba(255,255,255,.5);
    padding: 50px 20px;
    border-radius: 10px;;
}

.admin-header {
    margin-top: -100px;
    margin-bottom: 20px;
}

.admin-logo {
    width: 280px;
}

.admin-button {
    margin-top: 20px;
}

.admin-input {
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    height: 50px;
    width: 300px;
    padding-bottom: 0px;
    border-color: #fff;
    background: rgba(255,255,255,.8)
}
.admin-input:hover,
.admin-input:focus{
    background: rgba(255,255,255,.9);
    border-color: #fff!important;
}

.admin-input-username {
    border-top-style: solid;
    border-radius: 5px 5px 0 0;
     
}

.admin-input-verify {
    border-radius: 0 0 5px 5px;
    
}

.admin-button {
    width: 300px;
    height: 50px;
    border-radius: 4px;
    background-color: #50a3a2;
}

.admin-icon {
    margin-left: 260px;
    margin-top: 10px;
    font-size: 30px;
    color: #bbb;
}

i {
    position: absolute;
}

.admin-captcha {
    position: absolute;
    margin-left: 205px;
    margin-top: -40px;
}



.bg-bubbles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.bg-bubbles li {
  position: absolute;
  list-style: none;
  display: block;
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.15);
  bottom: -160px;
  -webkit-animation: square 25s infinite;
  animation: square 25s infinite;
  -webkit-transition-timing-function: linear;
  transition-timing-function: linear;
}
.bg-bubbles li:nth-child(1) {
  left: 10%;
}
.bg-bubbles li:nth-child(2) {
  left: 20%;
  width: 80px;
  height: 80px;
  -webkit-animation-delay: 2s;
          animation-delay: 2s;
  -webkit-animation-duration: 17s;
          animation-duration: 17s;
}
.bg-bubbles li:nth-child(3) {
  left: 25%;
  -webkit-animation-delay: 4s;
          animation-delay: 4s;
}
.bg-bubbles li:nth-child(4) {
  left: 40%;
  width: 60px;
  height: 60px;
  -webkit-animation-duration: 22s;
          animation-duration: 22s;
  background-color: rgba(255, 255, 255, 0.25);
}
.bg-bubbles li:nth-child(5) {
  left: 70%;
}
.bg-bubbles li:nth-child(6) {
  left: 80%;
  width: 120px;
  height: 120px;
  -webkit-animation-delay: 3s;
          animation-delay: 3s;
  background-color: rgba(255, 255, 255, 0.2);
}
.bg-bubbles li:nth-child(7) {
  left: 32%;
  width: 160px;
  height: 160px;
  -webkit-animation-delay: 7s;
          animation-delay: 7s;
}
.bg-bubbles li:nth-child(8) {
  left: 55%;
  width: 20px;
  height: 20px;
  -webkit-animation-delay: 15s;
          animation-delay: 15s;
  -webkit-animation-duration: 40s;
          animation-duration: 40s;
}
.bg-bubbles li:nth-child(9) {
  left: 25%;
  width: 10px;
  height: 10px;
  -webkit-animation-delay: 2s;
          animation-delay: 2s;
  -webkit-animation-duration: 40s;
          animation-duration: 40s;
  background-color: rgba(255, 255, 255, 0.3);
}
.bg-bubbles li:nth-child(10) {
  left: 90%;
  width: 160px;
  height: 160px;
  -webkit-animation-delay: 11s;
          animation-delay: 11s;
}
@-webkit-keyframes square {
  0% {
    -webkit-transform: translateY(0);
            transform: translateY(0);
  }
  100% {
    -webkit-transform: translateY(-1000px) rotate(600deg);
            transform: translateY(-1000px) rotate(600deg);
  }
}
@keyframes square {
  0% {
    -webkit-transform: translateY(0);
            transform: translateY(0);
  }
  100% {
    -webkit-transform: translateY(-1000px) rotate(600deg);
            transform: translateY(-1000px) rotate(600deg);
  }
}


</style>